//
//  CircleMineViewModel.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/3.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "CircleMineViewModel.h"
#import "CircleMineTableViewCell.h"
#import "CircleMineTitleImageCell.h"
#import "InputCommentViewModel.h"
#import "NoDataFootTableViewHeaderFooterView.h"

@interface CircleMineViewModel ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *selfTableView;
    NSArray *dataArr;
    InputCommentViewModel *boViewModel;
}

@end

@implementation CircleMineViewModel

- (instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        
        selfTableView = tableView;
        selfTableView.delegate = self;
        selfTableView.dataSource = self;
        selfTableView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        selfTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        
        selfTableView.mj_footer.hidden = YES;
        selfTableView.mj_header.hidden = YES;
        selfTableView.sectionFooterHeight = 0.0;
        selfTableView.sectionHeaderHeight = 0.0;
        [selfTableView registerClass:[NoDataFootTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        [superView addSubview:selfTableView];
        
        if ([selfTableView respondsToSelector:@selector(setSeparatorInset:)]) {
            [selfTableView setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
        }
        
        dataArr = @[@[@"我的帖子", @"我喜欢的", @"我的回帖"],@[@"回复我的", @"我的评论"]];
//        boViewModel = [[InputCommentViewModel alloc] initWithSuperView:superView];
//        boViewModel.BlockReturnTextView = ^(GLGWTextView * _Nullable textV, NSString * _Nonnull doneText) {
//            DLog(@"%@", doneText);
//        };

    }
    return self;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return kHeightProportion_In_iPhoneTriploid(10);
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    NoDataFootTableViewHeaderFooterView *footer = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return footer;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    } else if (section == 1) {
        return 3;
    } else if (section == 2) {
        return 2;
    }
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 91;
    }
    return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CircleMineTableViewCell *cell = [CircleMineTableViewCell cellWithTableView:tableView];
    if (indexPath.section == 0) {
        CircleMineTitleImageCell *cell = [CircleMineTitleImageCell cellWithTableView:tableView];
        cell.imageView.image = [UIImage imageNamed:@"Qcode_p"];
        cell.textLabel.text = @"李姐";
        return cell;
    }
    cell.textLabel.text = dataArr[indexPath.section-1][indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.BlockMineSelect) {
        self.BlockMineSelect(indexPath);
    }
}
@end
